package com.ewzj.bigdata.mvp.ui.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.ewzj.bigdata.R
import com.ewzj.bigdata.app.extensions.loadImgwithloading
import com.ewzj.bigdata.app.utils.Apputils
import com.ewzj.bigdata.mvp.model.rspbean.MsgBean
import com.ewzj.bigdata.mvp.ui.activity.WebViewActivity

/**
 * author:zhangjing
 * 作用:
 * return:
 */

class MsgAdapter(data: List<MsgBean>) : BaseQuickAdapter<MsgBean, BaseViewHolder>(R.layout.item_msg, data) {

    override fun convert(baseViewHolder: BaseViewHolder, msgBean: MsgBean) {
        if (msgBean.is_read == 1) {
            (baseViewHolder.getView<View>(R.id.tv_title) as TextView).setTextColor(mContext.resources.getColor(R.color.color_text_gray))
        } else {
            (baseViewHolder.getView<View>(R.id.tv_title) as TextView).setTextColor(mContext.resources.getColor(R.color.color_black))
        }
        baseViewHolder.getView<ImageView>(R.id.iv_msg).loadImgwithloading(Apputils.Utils.getImgUrl(msgBean.logo_image))
//        AppUtils.loadImgwithloading(mContext, AppUtils.getImgUrl(msgBean.logo_image), baseViewHolder.getView<View>(R.id.iv_msg) as ImageView)
        baseViewHolder.setText(R.id.tv_title, msgBean.title)
        baseViewHolder.setText(R.id.tv_content, msgBean.content)
        baseViewHolder.getConvertView().setOnClickListener { WebViewActivity.startWebView(mContext, msgBean.title, msgBean.go_url) }
    }
}
